package br.ufmg.vod.wbr.algorithims.dfs;

import br.ufmg.vod.collections.IntQueueStack;
import br.ufmg.vod.collections.IntStack;
import br.ufmg.vod.wbr.api.Graph;

public class DFSData{
	
	public static byte WHITE = 0;
	public static byte GRAY = 1;
	public static byte BLACK = 2;
	
	
	Graph graph;
	public int time;
	public int[] predecessor;
	public int[] dist;
	public int[] discoveryTime;
	public int[] closeTime;
	public byte[] colors;
	public int startVertex;
	public IntStack visitedStack;
	
	
	public DFSData(Graph g){

		this.graph = g;
		this.time=0;
		this.predecessor = new int[g.getNumVertex()];
		this.dist = new int[g.getNumVertex()];
		this.discoveryTime = new int[g.getNumVertex()];
		this.closeTime = new int[g.getNumVertex()];
		this.colors = new byte[g.getNumVertex()];
		this.visitedStack = new IntQueueStack(this.graph.getNumVertex());
		
		this.clearAllData();
	}


	void clearAllData() {
		this.visitedStack.clear();
		for (int i = 0; i < this.graph.getNumVertex(); i++) {
			this.predecessor[i]=-1;
			this.dist[i]= Integer.MAX_VALUE;
			this.discoveryTime[i]=-1;
			this.closeTime[i]=-1;
			this.colors[i]=WHITE;
		}
	}
	
	void clearAllVisitedData() {
		
		while(!this.visitedStack.isEmpty()) {
			int i = this.visitedStack.pop();
			this.predecessor[i]=-1;
			this.dist[i]= Integer.MAX_VALUE;
			this.discoveryTime[i]=-1;
			this.closeTime[i]=-1;
			this.colors[i]=WHITE;
		}
	}
	

	
	
}
